
Instructions for replicating analyses presented in Steven Liao. 
"The Effect of Firm Lobbying on High-Skilled Visa Adjudication." 
The Journal of Politics.


######################################################################
*** I. Install Dependencies *** 
######################################################################

Replication created on a iMac (3.6 Ghz 10-Core Intel Core i9 with 
64 GB 2667 MHz DDR4) running macOS Monterey (12.6) using 
R (version 4.1.1) via RStudio (version 2021.09.0). Please install the 
following R packages used in the analyses.

- concordance: version = 2.0.0

- devtools: version = 2.4.3

- gridExtra: version = 2.3

- lfe: version = 2.8-7.1

- mvtnorm: version = 1.1-3

- PanelMatch: version = 2.0.1 (developer's version, see 
  DID-matching-analysis.R for installation instructions)

- RColorBrewer: version = 1.1-3

- stargazer: version = 5.2.3

- stm: version = 1.3.6

- stringdist: version = 0.9.8

- tidyverse: version = 1.3.1

- viridis: version = 0.6.2

- xtable: version = 1.8-4


######################################################################
*** II. Datasets ***
######################################################################

The following files are main datasets used in the analyses. 
Please make sure to download all files in their original format.

NOTE: Orbis data are proprietary and prohibited from sharing publicly. 
To protect Orbis' proprietary data, I have excluded all variables showing 
Orbis data. However, to facilitate the replication of all figures and 
tables in the manuscript, I have included saved and anonymous analysis 
outputs when they are needed (see Section IV below). Orbis data can 
be accessed with a subscription through Bureau Van Dijk's Orbis database 
<https://oldorbis.bvdinfo.com/>. To download the Orbis data used in 
this study, upload the list of BvD IDs included in 
"data-merge-91-17-orbis-excluded.RData" below as Identification Numbers. 
Orbis will then search and return firm-level information on the matched 
firms. Users can change the set of variables Orbis returns. I used the 
following variables: "NAICS 2017, core code (4 digits)", 
"NAICS 2017, core code - description", "Size classification", "Quoted", 
"Sales th USD", and "Number of employees".

  
- lv-imm-fr-99-17-rep.RData 
  A report-level dataset used in the analysis "Figure-1.R". The 
  dataset contains 18 variables and 7,297 observations.

- lv-imm-fy-99-17-rep.RData 
  A firm-year dataset used in the analysis "Figure-3.R". The dataset 
  contains 5 variables and 2,196 observations.

- data-merge-91-17-orbis-excluded.RData 
  An unbalanced firm-year dataset that excludes proprietary Orbis 
  variables. The dataset contains 64 variables and 1,243,396 
  observations. The dataset is the same as data-merge-91-17.RData 
  but with Orbis variables excluded. The latter full dataset is documented 
  in the code but not shared for proprietary data protection reasons. 
  The dataset is used in analyses:
    1) Figure-4-Appendix-Table-D3-D4-D5.R 
    2) Figure-6-Appendix-Figure-D1.R
    3) DID-analysis.R
    4) Appendix-Figure-B1.R
    5) Appendix-Table-D1.R

- lv-imm-fr-2008-2017-checked-orbis-excluded.RData
  A manually checked report-level dataset (2008-2017) 
  that excludes proprietary Orbis variables and data. It shows what 
  the text analysis input data looks like in Figure-5-C2-C3-C4.R 
  but without Orbis variables. The dataset contains 13 variables and 
  5,705 observations.

- lv-imm-fr-1999-2007-checked-orbis-excluded.RData 
  A manually checked report-level dataset (1999-2007) 
  that excludes proprietary Orbis variables and data. This dataset is 
  discussed in Section 4 "Data and Measures" of the manuscript. 
  The dataset contains 13 variables and 1,565 observations. 


For JOP reporting purposes, the following files are supplementary 
datasets that archive raw or manually checked LobbyView data. I use 
them to show how LobbyView data is acquired and cleaned for 
merging. Please make sure to download all files in their original format.

- lv-imm-reports-99-17-raw.RData
  A report-issue-level raw dataset (1999-2017) focusing on reports 
  containing IMM issue codes. The query data were downloaded from 
  LobbyView's website and are used in "prep-lobbyview-data.R". The 
  dataset contains 17 variables and 166,244 observations.

- lv-check-v1-venue-text-2000-2007.csv
  A report-level dataset containing some manually checked information 
  on immigration lobbying venues and text (2000-2007). The dataset is 
  used in "prep-lobbyview-data.R" and contains 8 variables and 416 
  observations.

- lv-check-v2-venue-text-1999-2017.csv
  A report-level dataset containing some manually checked information 
  on immigration lobby venues and text (1999-2017). The dataset is used 
  in "prep-lobbyview-data.R" and contains 10 variables and 1,537 
  observations.

- lv-check-v3-amount-1999-2007.csv
  A report-level dataset containing some manually checked information on 
  immigration lobbying expenditures (1999-2007). The dataset is used 
  in "prep-lobbyview-data.R" and contains 8 variables and 86 
  observations.

- lv-check-venues-1999-2017.csv
  A report-level dataset containing some manually checked information on 
  immigration lobbying target venues (1999-2007). The dataset is used 
  in "prep-lobbyview-data.R" and contains 8 variables and 352 
  observations.

- lv-other-reports-17-raw.RData
  A report-level raw dataset (2017) focusing on other select lobbying 
  issue codes. The data were acquired directly from LobbyView's 
  principal investigator and are used in "prep-lobbyview-data.R". The 
  dataset contains 9 variables and 66,818 observations.

- lv-all-report-issue-17-raw.RData
  A report-issue-level raw dataset that contains all lobbying reports 
  and issue codes in 2017. The data were downloaded from LobbyView's 
  and are used in "prep-lobbyview-data.R". The dataset contains 18 
  variables and 146,065 observations.


######################################################################
*** III. R codes ***
######################################################################

The R scripts below will reproduce all the figures and
tables in the main text and appendix. Please set the working directory 
to where this instruction file is located by changing MAIN_DIR in each 
R script.

NOTE: As discussed above, some scripts use Orbis' proprietary data. 
In these cases, I document the exact R code for implementing the 
analyses, save the resulting anonymous outputs, and load the saved 
outputs to reproduce the related figures/tables.

1) Figure-1.R creates Figure 1

2) Figure-2.R creates Figure 2

3) Figure-3.R creates Figure 3

4) Figure-4-Appendix-Table-D3-D4-D5.R creates:
   Figure 4
   Appendix Tables D.3, D.4, and D.5

5) Figures-5-C2-C3-C4.R creates:
   Figure 5
   Appendix Figures C.2, C.3, and C.4

6) Figure-6-Appendix-Figure-D1.R creates:
   Figure 6
   Appendix Figure D.1

7) DID-analysis.R creates: 
   Figure 7
   Appendix Tables D.6, D.7, D.8, D.11, D.12, D.13, D.14, and D.15

8) DID-matching-analysis.R creates: 
   Appendix Figure D.2
   Appendix Tables D.9 and D.10 

9) Appendix-Figure-B1.R creates Appendix Figure B.1

10) Appendix-Table-D1.R creates Appendix Table D.1

11) Appendix-Table-D2.R creates Appendix Table D.2


For JOP reporting purposes, the R scripts below documents how I acquired 
LobbyView data and cleaned them for merging. Note that since Orbis data 
are proprietary and prohibited from sharing publicly, merge-data.R, 
which relies on Orbis data in the merge, serves only for documentation 
purposes and can not be run.

1) prep-lobbyview-data.R recreates lobbying data loaded in merge-data.R

2) merge-data.R documents how I merged and created the full dataset 
   data-merge-91-17.RData


######################################################################
*** IV. Files Uploaded for File-Level Preservation ***
######################################################################

The following files are saved outputs used/described in the R scripts 
above. The R scripts document exactly how they are produced. As discussed 
above, the files help protect proprietary data while facilitating 
replication. Please make sure to download all files in their original 
format.

- Figure-2-data-anonymous.RData 
  A saved anonymous firm-level dataframe that excludes firm identifiers 
  and with rows randomly reshuffled. It is used in Figure-2.R
  to generate Figure 2.

- data.persist-ph.RData 
  A saved firm-year dataframe that indicates complete firm-year 
  combinations between when firms first and last existed. It is 
  used in Figure-4-Appendix-Table-D3-D4-D5.R to ease computational 
  time.

- prev-fit-k5-2008-2017-firm-quarter-low-thres-100.RData
  Saved anonymous STM results from the 5-topic model used in 
  Figures-5-C2-C3-C4.R to generate Figure 5.

- sim-df-k5-2008-2017-firm-quarter-low-thres-100.RData
  Saved anonymous simulation results from the 5-topic model used in 
  Figures-5-C2-C3-C4.R to generate Appendix Figure C.4.

- searchK-storage-2008-2017-firm-quarter-low-thres-100.RData
  Saved anonymous searchK STM results used in Figures-5-C2-C3-C4.R
  to generate Appendix Figure C.2.

- prev-fit-k4-2008-2017-firm-quarter-low-thres-100.RData
  Saved anonymous STM results from the 4-topic model used in 
  Figures-5-C2-C3-C4.R to generate Appendix Figure C.3.

- Appendix-Table-D1-data-anonymous.RData 
  Saved anonymous summary results for Orbis variables used in 
  Appendix-Table-D1.R to generate Appendix Table D.1.

- Appendix-Table-D2-data-anonymous.RData
  Saved anonymous summary results by NAICS industry.
  The data is used in Appendix-Table-D2.R to generate Appendix 
  Table D.2.

- data-pm-08-17-orbis-excluded.RData
  A saved firm-year dataframe that shows what the PanelMatch input 
  data looks like in DID-matching-analysis.R but with Orbis variables 
  excluded.

- Appendix-Table-D12-sales-outliers.RData
  Saved unique identifiers of 2017 sales outlier firms extracted 
  from Orbis data. The data is used in DID-analysis.R to generate 
  columns (1) and (2) of Appendix Table D.12.

- Appendix-Table-D12-employ-outliers.RData
  Saved unique identifiers of 2017 employment outlier firms extracted 
  from Orbis data. The data is used in DID-analysis.R to generate 
  columns (3) and (4) of Appendix Table D.12.

- Appendix-Table-D13-c1-anonymous-output.RData
  Saved anonymous regression output data used in DID-analysis.R to 
  generate column (1) of Appendix Table D.13. 

- Appendix-Table-D13-c2-anonymous-output.RData
  Saved anonymous regression output data used in DID-analysis.R to 
  generate column (2) of Appendix Table D.13. 

- Appendix-Table-D13-c3-anonymous-output.RData
  Saved anonymous regression output data used in DID-analysis.R to 
  generate column (3) of Appendix Table D.13. 

- PM-08-17-l1.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (1) of Appendix Table D.9. 

- balance-08-17-l1.RData
  Saved anonymous balance results used in DID-matching-analysis.R to 
  generate column (1) of Appendix Table D.10. 

- PE-08-17-l1.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (1) of Appendix Table D.9. 

- PM-08-17-l1-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (1) of Appendix Table D.9. 

- balance-08-17-l1-em.RData
  Saved anonymous balance results used in DID-matching-analysis.R to 
  generate column (2) of Appendix Table D.10. 

- PE-08-17-l1-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (1) of Appendix Table D.9. 

- PM-08-17-l1-text.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (2) of Appendix Table D.9. 

- balance-08-17-l1-text.RData
  Saved anonymous balance results used in DID-matching-analysis.R to 
  generate column (3) of Appendix Table D.10. 

- PE-08-17-l1-text.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (2) of Appendix Table D.9. 

- PM-08-17-l1-text-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (2) of Appendix Table D.9. 

- balance-08-17-l1-text-em.RData"
  Saved anonymous balance results used in DID-matching-analysis.R to 
  generate column (4) of Appendix Table D.10. 

- PE-08-17-l1-text-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (2) of Appendix Table D.9. 

- PM-08-17-l1-text-only-congress.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (3) of Appendix Table D.9. 

- balance-08-17-l1-text-only-congress.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-only-congress.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (3) of Appendix Table D.9. 

- PM-08-17-l1-text-only-congress-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (3) of Appendix Table D.9. 

- balance-08-17-l1-text-only-congress-em.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-only-congress-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (3) of Appendix Table D.9. 

- PM-08-17-l1-text-uscis.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (4) of Appendix Table D.9. 

- balance-08-17-l1-text-uscis.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-uscis.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (4) of Appendix Table D.9. 

- PM-08-17-l1-text-uscis-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (4) of Appendix Table D.9. 

- balance-08-17-l1-text-uscis-em.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-uscis-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (4) of Appendix Table D.9. 

- PM-08-17-l1-text-dol.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (5) of Appendix Table D.9. 

- balance-08-17-l1-text-dol.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-dol.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (5) of Appendix Table D.9. 

- PM-08-17-l1-text-dol-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (5) of Appendix Table D.9. 

- balance-08-17-l1-text-dol-em.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-dol-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (5) of Appendix Table D.9. 

- PM-08-17-l1-text-dhs.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (6) of Appendix Table D.9. 

- balance-08-17-l1-text-dhs.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-dhs.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (6) of Appendix Table D.9. 

- PM-08-17-l1-text-dhs-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (6) of Appendix Table D.9. 

- balance-08-17-l1-text-dhs-em.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-dhs-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (6) of Appendix Table D.9. 

- PM-08-17-l1-text-wh-eop.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (1) row (7) of Appendix Table D.9. 

- balance-08-17-l1-text-wh-eop.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-wh-eop.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (1) row (7) of Appendix Table D.9. 

- PM-08-17-l1-text-wh-eop-em.RData
  Saved anonymous match results used in DID-matching-analysis.R 
  to estimate column (2) row (7) of Appendix Table D.9. 

- balance-08-17-l1-text-wh-eop-em.RData
  Saved anonymous balance results for file-level preservation purposes 
  as indicated in Appendix Table D.10.

- PE-08-17-l1-text-wh-eop-em.RData
  Saved anonymous estimation results used in DID-matching-analysis.R 
  to generate column (2) row (7) of Appendix Table D.9. 

